package com.drama.api.base;

import com.github.pagehelper.PageInfo;
import lombok.Data;

@Data
public class PageBean<T> {

    private Long totalPage;

    private Long totalCount;

    private Long currentPage;

    private Long pageSize;

    private T data;

    public static PageBean build(PageInfo pageInfo) {
        if (pageInfo == null) {
            return null;
        }
        PageBean pageBean = new PageBean();
        pageBean.setCurrentPage((long) pageInfo.getPageNum());
        pageBean.setPageSize((long) pageInfo.getPageSize());
        pageBean.setTotalPage((long) pageInfo.getPages());
        pageBean.setTotalCount(pageInfo.getTotal());
        pageBean.setData(pageInfo.getList());
        return pageBean;
    }

}
